package com.douqu.game.core.entity.ext;

import com.bean.core.buffer.ByteBuffer;
import com.douqu.game.core.entity.GameObject;
import com.douqu.game.core.entity.WorldInfo;
import com.douqu.game.core.entity.InitData;
import com.douqu.game.core.controller.PlayerController;
import com.douqu.game.core.entity.common.TwoTuple;
import com.douqu.game.core.entity.goods.Goods;
import com.douqu.game.core.entity.goods.GoodsEquip;
import com.douqu.game.core.entity.goods.GoodsProp;
import com.douqu.game.core.entity.common.CommonData;
import com.douqu.game.core.entity.sprite.*;
import com.douqu.game.core.entity.sprite.Player;
import com.douqu.game.core.entity.sprite.CardLv;
import com.douqu.game.core.entity.sprite.CardQuality;
import com.douqu.game.core.factory.ConstantFactory;
import com.douqu.game.core.factory.DataFactory;
import com.douqu.game.core.factory.WordFactory;
import com.douqu.game.core.protobuf.SGBagProto;
import com.douqu.game.core.protobuf.SGCommonProto.E_NOTIFY_TYPE;
import com.douqu.game.core.protobuf.SGMainProto;
import com.douqu.game.core.util.SendUtils;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * Created by bean on 2017/7/17.
 */
public class BagInfo extends ExtInfo {

//    private Logger logger = Logger.getLogger(this.getClass());

    /**玩家所有的卡片list */
    private List<Card> cardList;

    /**玩家所有的卡片map*/
    private Map<Integer,Card> cardMap;

    /**玩家卡组*/
    private Map<Integer,List<Integer>> cardTeamMap;

    /**上阵卡组 对应teamMap的key*/
    private int battleCardIndex;

    /**
     * 资源数据
     * key:资源ID
     * value:资源数量
     */
    private Map<Integer,Integer> assetData;

    /**
     * 所有道具列表
     */
    private List<Goods> goodsList;

    /**
     * 所有道具+装备
     * key:流水号
     * value:道具或装备
     */
    private Map<String, Goods> goodsMap;
    /**
     * 根据物品分类存储一下，方便取分类数据
     */
    private Map<Integer, List<Goods>> goodsTypeMap;


    public BagInfo(Player player, WorldInfo worldInfo)
    {
        super(player, worldInfo);

        clear();
    }

    private void clear()
    {
        cardList = new ArrayList<>();
        cardMap = new HashMap<>();
        cardTeamMap = new ConcurrentHashMap<>();

        assetData = new ConcurrentHashMap<>();
        goodsList = new ArrayList<>();
        goodsMap = new ConcurrentHashMap<>();
        goodsTypeMap = new ConcurrentHashMap<>();
    }


    @Override
    public void writeTo(ByteBuffer buffer)
    {
        buffer.writeByte(battleCardIndex);

        buffer.writeByte(assetData.size());
        for(Integer key : assetData.keySet())
        {
            buffer.writeInt(key);
            buffer.writeInt(assetData.get(key));
        }

        buffer.writeShort(cardList.size());
        for(Card card : cardList)
        {
            buffer.writeInt(card.id);
            card.writeTo(buffer);
        }

        buffer.writeShort(goodsList.size());
        for(Goods goods : goodsList)
        {
            buffer.writeInt(goods.id);
            goods.writeTo(buffer);
        }

        buffer.writeByte(cardTeamMap.size());
        for(Integer key : cardTeamMap.keySet())
        {
            buffer.writeByte(cardTeamMap.get(key).size());
            for(Integer id : cardTeamMap.get(key))
            {
                buffer.writeInt(id);
            }
            buffer.writeByte(key);
        }

        buffer.writeInt(0);//备用
    }

    @Override
    public void loadFrom(ByteBuffer buffer)
    {
        clear();

        battleCardIndex = buffer.readByte();

        //读取资源数据
        int size = buffer.readByte();
        int i = 0;
        for(i = 0; i < size; i++)
        {
            assetData.put(buffer.readInt(), buffer.readInt());
        }

        //读取卡牌数据
        size = buffer.readShort();
        GameObject dbObj = null, dataObj = null;
        DataFactory dataFactory = DataFactory.getInstance();
        int id = 0;
        for(i = 0; i < size; i++)
        {
            id = buffer.readInt();
            dataObj = dataFactory.getGameObject(DataFactory.CARD_KEY, id);
            if(dataObj == null || !(dataObj instanceof Card))
            {
                System.out.println("BagInfo load error -> Card is null:" + id);
            }
            else
            {
                dbObj = GameObject.cloneObject(dataObj);
                dbObj.loadFrom(buffer);
                cardList.add((Card) dbObj);
                cardMap.put(dbObj.getId(), (Card) dbObj);
            }
        }

        //读取道具和装备
        size = buffer.readShort();
        List<Goods> list = null;
        for(i = 0; i < size; i++)
        {
            id = buffer.readInt();
            dataObj = dataFactory.getGameObject(DataFactory.GOODS_KEY, id);
            if(dataObj == null || !(dataObj instanceof Goods))
            {
                System.out.println("BagInfo load error -> Goods is null:" + id);
            }
            else
            {
                dbObj = GameObject.cloneObject(dataObj);
                dbObj.loadFrom(buffer);
                goodsList.add((Goods) dbObj);
                goodsMap.put(dbObj.getObjectIndex(), (Goods) dbObj);
                list = goodsTypeMap.get(((Goods) dbObj).getType());
                if(list == null)
                {
                    list = new ArrayList<>();
                    goodsTypeMap.put(((Goods) dbObj).getType(), list);
                }
                list.add((Goods) dbObj);
            }
        }

        //读取卡组数据
        size = buffer.readByte();
        int len = 0;
        List<Integer> cardIds = null;
        for(i = 0; i < size; i++)
        {
            len = buffer.readByte();
            cardIds = new ArrayList<>();
            for(int j = 0; j < len; j++)
            {
                cardIds.add(buffer.readInt());
            }
            cardTeamMap.put(buffer.readByte(), cardIds);
        }


        buffer.readInt();//备用
    }



    /**
     * 创建角色的时候初始化
     */
    public void init()
    {
        if(cardList.size() > 0)//有数据了表示已经初始化过了
            return;

        clear();

        DataFactory dataFactory = DataFactory.getInstance();

        InitData initData = dataFactory.getInitData();

        for(CommonData data : initData.initAssets)
        {
            assetData.put(data.id, data.value);
        }

        GoodsProp prop = null;
        GoodsProp bagProp = null;
        List<Goods> list = null;
        for(CommonData data : initData.initProps)
        {
            prop = dataFactory.getGameObject(DataFactory.GOODS_PROP_KEY, data.id);
            bagProp = (GoodsProp) GameObject.cloneObject(prop);
            bagProp.setObjectIndex(worldInfo.createGoodsIndex());
            bagProp.setCount(data.value);

            goodsList.add(bagProp);
            goodsMap.put(bagProp.getObjectIndex(), bagProp);
            list = goodsTypeMap.get(bagProp.getType());
            if(list == null)
            {
                list = new ArrayList<>();
                goodsTypeMap.put(bagProp.getType(), list);
            }
            list.add(bagProp);
        }

        Card card = null;
        Card bagCard = null;

        for(Integer id :  initData.initCards)
        {
            card = dataFactory.getGameObject(DataFactory.CARD_KEY, id);
            bagCard = (Card) GameObject.cloneObject(card);

            cardList.add(bagCard);
            cardMap.put(id, bagCard);
        }

        PlayerLv playerLv = dataFactory.getGameObject(DataFactory.PLAYER_LV_KEY, player.getLv());
        if(playerLv != null)
        {
            if(playerLv.battleSoldierCount > cardList.size())
            {
                System.out.println("BagInfo Init Error:battleSoldierCount error!");
            }
            else
            {
                List<Integer> cardIds = new ArrayList<>();
                for(int i = 0; i < playerLv.battleSoldierCount; i++)
                {
                    cardIds.add(cardList.get(i).getId());
                }
                cardTeamMap.put(1, cardIds);
                cardTeamMap.put(2, cardIds);
                cardTeamMap.put(3, cardIds);
                battleCardIndex = 1;
            }
        }

    }

    /***
     * 添加卡片
     * result : TwoTuple ,first表示是卡牌 second表示是道具
     */
    public TwoTuple<CommonData,CommonData> addCard(PlayerController playerController, int id, int count)
    {
        if(count <= 0)
        {
            playerController.sendAlert(E_NOTIFY_TYPE.NOTIFY_TYPE_WARN, WordFactory.getWord(WordFactory.PARAM_ERROR));
            return null;
        }

        //在配置文件中根据id 来获取卡牌对象
        Card card =  DataFactory.getInstance().getGameObject(DataFactory.CARD_KEY, id);
        if(card == null)
        {
            playerController.sendAlert(E_NOTIFY_TYPE.NOTIFY_TYPE_WARN, WordFactory.getWord(WordFactory.PARAM_ERROR));
            return null;
        }


        if(getCard(id) != null)
        {
            //分解成碎片
            addGoods(null, card.lvUpProp, count*10);

            return new TwoTuple<CommonData,CommonData>(null,new CommonData(card.lvUpProp,count*10));
        }
        else
        {
            //克隆新的对象
            Card newCard =  (Card) GameObject.cloneObject(card);

            //卡片添加到list、map
            cardList.add(newCard);
            cardMap.put(id,newCard);

            return new TwoTuple<CommonData,CommonData>(new CommonData(id,count),null);
        }
    }


    /***
     * 获取单个卡片信息
     * @param id
     * @return
     */
    public Card getCard(int id){
        return cardMap.get(id);
    }

    /**
     * 添加资源
     * @param key
     * @param value
     */
    public void addAsset(int key, int value)
    {
        int newValue = value;

        Integer resValue = assetData.get(key);
        if(resValue != null)
            newValue += resValue;

        newValue = newValue < 0 ? 0 : newValue;

        assetData.put(key, newValue);
    }

    /**
     * 获取资源数量
     * @param key
     * @return
     */
    public int getAsset(int key)
    {
        return assetData.get(key);
    }

    public Goods getGoodsById(int goodsId)
    {
        for(Goods goods : goodsList)
        {
            if(goods.getId() == goodsId)
                return goods;
        }
        return null;
    }

    /***
     * 当前物品剩余可叠加数量
     * @param goodsId
     * @param maxCount
     * @return
     */
    public int getRemainingCount(int goodsId, int maxCount) {
        int count = 0;
        for(Goods goods : goodsList) {
            if(goods.getId() == goodsId) {
                count += maxCount - goods.count;
            }
        }
        return count;
    }



    /**
     * 添加物品
     * @param goodsId
     * @param count 返回添加后的数量,如果为-1表示数据错误
     * @return
     */
    public int addGoods(PlayerController playerController, int goodsId, int count)
    {
        System.out.println("添加物品ID:" + goodsId + "  添加数量:" + count);
        if(count == 0)
        {
            playerController.sendAlert(E_NOTIFY_TYPE.NOTIFY_TYPE_WARN, WordFactory.getWord(WordFactory.PARAM_ERROR));
            System.out.println("物品数量错误");
            return -1;
        }

        Goods goods = DataFactory.getInstance().getGameObject(DataFactory.GOODS_KEY, goodsId);
        if(goods == null)
        {
            playerController.sendAlert(E_NOTIFY_TYPE.NOTIFY_TYPE_WARN, WordFactory.getWord(WordFactory.OBJECT_NOT_EXIST));
            System.out.println("物品不存在");
            //物品不存在
            return -1;
        }

        List<Goods> typeGoodsList = goodsTypeMap.get(goods.getType());
        if(count > 0)
        {
            if(typeGoodsList == null)
            {
                typeGoodsList = new CopyOnWriteArrayList<>();
                goodsTypeMap.put(goods.getType(), typeGoodsList);
            }
        }

        int result = 0;

        if(goods instanceof GoodsProp)
        {
            Goods bagGoods = getGoodsById(goodsId);
            if(count > 0)
            {
                //添加物品
                if(bagGoods == null)
                {
                    bagGoods = (Goods) Goods.cloneObject(goods);
                    bagGoods.objectIndex = worldInfo.createGoodsIndex();
                    bagGoods.count = count;
                    goodsList.add(bagGoods);
                    typeGoodsList.add(bagGoods);
                    goodsMap.put(bagGoods.objectIndex, bagGoods);
                }
                else
                {
                    bagGoods.count += count;
                }

                result = bagGoods.count;
            }
            else
            {
                //删除物品
                if(bagGoods == null || bagGoods.count < Math.abs(count))
                {
                    playerController.sendAlert(E_NOTIFY_TYPE.NOTIFY_TYPE_WARN, DataFactory.getInstance().getWord(WordFactory.PARAM_ERROR));
                    //物品数量错误
                    return -1;
                }

                bagGoods.count += count;

                result = bagGoods.count;
            }

            return result;
        }
        else if(goods instanceof GoodsEquip)
        {
            int syCount = Math.abs(count);
            if(count > 0)
            {
                Goods bagEquip = null;
                for(int i = 0; i < syCount; i++)
                {
                    bagEquip = (Goods) Goods.cloneObject(goods);
                    bagEquip.objectIndex = worldInfo.createGoodsIndex();
                    bagEquip.count = 1;
                    goodsList.add(bagEquip);
                    typeGoodsList.add(bagEquip);
                    goodsMap.put(bagEquip.objectIndex, bagEquip);
                }
            }
            else
            {
                if(getGoodsCount(goodsId) < Math.abs(count))
                {
                    playerController.sendAlert(E_NOTIFY_TYPE.NOTIFY_TYPE_WARN, WordFactory.getWord(WordFactory.PARAM_ERROR));
                    System.out.println("物品数量错误");
                    //物品不存在
                    return -1;
                }

                for(Goods equip : typeGoodsList)
                {
                    goodsList.remove(equip);
                    typeGoodsList.remove(equip);
                    goodsMap.remove(equip.objectIndex);

                    if(--syCount <= 0)
                        break;
                }
            }

            return getGoodsCount(goodsId);
        }
        else
            return -1;
    }


    /**
     * 根据流水号获取物品
     * @param objectIndex
     * @return
     */
    public Goods getGoodsByObjectIndex(String objectIndex)
    {
        return goodsMap.get(objectIndex);
    }

//    /**
//     * 获取道具数量
//     * @param id
//     * @return
//     */
//    public int getPropCount(int id)
//    {
//        int count = 0;
//        for(Goods goods : goodsList)
//        {
//            if(goods.getId() == id)
//                count += goods.getCount();
//        }
//        return count;
//    }


    /**
     * 获取上阵卡组
     * @return
     */
    public List<Card> getBattleCards() {
        List<Card> list = new ArrayList<>();
        List<Integer> ids = cardTeamMap.get(battleCardIndex);
        if(ids == null)
        {
            //数据异常
            return list;
        }

        for(Integer id : ids)
        {
            list.add(cardMap.get(id));
        }

        return list;
    }



    /***
     * 玩家对卡牌进行升级
     * @param playerController
     * @param sid
     */
    public void cardLV(PlayerController playerController, int sid)
    {
        //获取兵种
        Card card =  getCard(sid);
        //检测是否拥有此兵种
        if(card == null)
        {
            playerController.sendAlert(E_NOTIFY_TYPE.NOTIFY_TYPE_WARN, WordFactory.getWord(WordFactory.CARD_NOTHING_ERROR));
            return;
        }

        //根据当前兵种等级在配置文件中获取下一级的配置信息
        CardLv lv = DataFactory.getInstance().getGameObject(DataFactory.CARD_LV_KEY, card.lv + 1);
        if(lv == null)
        {
            playerController.sendAlert(E_NOTIFY_TYPE.NOTIFY_TYPE_WARN, WordFactory.getWord(WordFactory.LV_MAX_ERROR));
            return;
        }

        //根据品质获取升级的一些数据
        CardQuality cardQuality = lv.getByQuality(card.quality);
        if(cardQuality == null){
            playerController.sendAlert(E_NOTIFY_TYPE.NOTIFY_TYPE_WARN, WordFactory.getWord(WordFactory.SERVER_DATA_ERROR));
            return;
        }
        //获取金币
        CommonData needAsset = cardQuality.getNeedAsset();
        if(needAsset != null) {
            if(getAsset(needAsset.id) < needAsset.value) {
                //需要的资源不够
                playerController.sendAlert(E_NOTIFY_TYPE.NOTIFY_TYPE_WARN, WordFactory.getWord(WordFactory.ASSET_NOT_ENOUGH, needAsset.id));
                return;
            }
        }
        //获取碎片
        int curCount = getGoodsCount(card.lvUpProp);
        System.out.print("消耗前的背包中碎片curCount:" + curCount);
        if(curCount < cardQuality.getNeedPropCount()) {
            //需要的碎片不够
            playerController.sendAlert(E_NOTIFY_TYPE.NOTIFY_TYPE_WARN, WordFactory.getWord(WordFactory.GOODS_NOT_ENOUGH, card.lvUpProp));
            return;
        }

        //消耗金币
        if(needAsset != null) {
            addAsset(needAsset.id, -needAsset.value);
        }
        //消耗碎片
        int result = addGoods(playerController,card.lvUpProp, -cardQuality.getNeedPropCount());
        if(result == -1)
            return;

        SGBagProto.S2C_CardLevelUp.Builder b = SGBagProto.S2C_CardLevelUp.newBuilder();
        b.setPropCount(curCount - cardQuality.getNeedPropCount());

        int curCount1 = getGoodsCount(card.lvUpProp);
        System.out.print("消耗后的背包中碎片curCount:" + curCount1);

        //设置升级后卡片等级
        card.lv = card.lv + 1;
        playerController.sendMsg(SGMainProto.E_MSG_ID.MsgID_Bag_CardLevelUp_VALUE,b.build().toByteArray());
        System.out.println("卡牌升级成功");
    }


//    /***
//     * 根据id获取所拥有的数量
//     * @return
//     */
//    public int getGoodsCountByType(int type, int goodsId){
//        List<Goods> cardList = goodsTypeMap.get(type);
//        int count = 0;
//        for(Goods goods : cardList){
//            if(goodsId == goods.id){
//                count += goods.count;
//            }
//        }
//        return count;
//    }

    /***
     * 根据id获取所拥有的数量
     * @return
     */
    public int getGoodsCount(int goodsId)
    {
        int count = 0;

        Goods goods = DataFactory.getInstance().getGameObject(DataFactory.GOODS_KEY, goodsId);
        if(goods == null)
            return 0;

        List<Goods> typeGoodsList = goodsTypeMap.get(goods.getType());
        if(typeGoodsList == null)
            return 0;

        for(Goods goodsObject : typeGoodsList)
        {
            if(goodsId == goodsObject.id){
                count += goodsObject.count;
            }
        }
        return count;
    }

    /***
     * 我的卡包列表
     */
    public void myCardList(PlayerController playerController)
    {

        System.out.println("进入我的卡包列表");

        SGBagProto.S2C_MyCardList.Builder b = SGBagProto.S2C_MyCardList.newBuilder();

        //返回我的卡包list
        for(Card card : cardList){
            SGBagProto.MyCardBagInfo.Builder c = SGBagProto.MyCardBagInfo.newBuilder();
            c.setCid(card.id);
            //已拥有的碎片
            c.setLvUpProp(getGoodsCount(card.lvUpProp));
            c.setType(card.type);
            c.setLv(card.getLv());
            b.addCardBagInfo(c);
            }
        System.out.println("卡包列表返回数据 :" + b.toString());
        //返回给客户端
        playerController.sendMsg(SGMainProto.E_MSG_ID.MsgID_Bag_MyCard_VALUE, b.build().toByteArray());
    }


    /***
     * 上阵卡组列表
     */
    public void myCardTeam(PlayerController playerController){

        SGBagProto.S2C_MyCardTeam.Builder b = SGBagProto.S2C_MyCardTeam.newBuilder();

        //取出上证卡组id
        for (Integer keyes : cardTeamMap.keySet()) {
            //当前的出战卡组
            if(battleCardIndex == keyes){
                b.setBattleCardTeamId(battleCardIndex);
            }
            SGBagProto.MyCardTeamInfo.Builder c = SGBagProto.MyCardTeamInfo.newBuilder();
            c.setCardTeamId(keyes);
            List<Integer> list = cardTeamMap.get(keyes);
            System.out.println("list.size:" + list.size());
            if(list != null && list.size() > ConstantFactory.ZERO) {
                for (int i = 0; i < list.size(); i++) {
                    Card card = getCard(list.get(i).intValue());
                    SGBagProto.MyCardBagInfo.Builder v = SGBagProto.MyCardBagInfo.newBuilder();
                    v.setLv(card.getLv());
                    //已拥有的碎片
                    v.setLvUpProp(getGoodsCount(card.lvUpProp));
                    v.setCid(card.id);
                    c.addCardInfo(v);
                }
            }

            b.addCardTeamInfo(c);
        }

        System.out.println("卡组列表返回数据：" + b.toString());
        //返回给客户端
        playerController.sendMsg(SGMainProto.E_MSG_ID.MsgID_Bag_MyCardTeam_VALUE, b.build().toByteArray());

    }


    /***
     * 设置上阵卡组
     * @param playerController
     * @param cardTeamId
     */
    public void setBattleCardTeam(PlayerController playerController,int cardTeamId) {

//        SGBagProto.S2S_SetBattleCardTeam.Builder b = SGBagProto.S2S_SetBattleCardTeam.newBuilder();
//
//        if(cardTeamMap != null && cardTeamMap.get(cardTeamId).size() > ConstantFactory.ZERO){
//            battleCardMap.put(cardTeamId,cardTeamMap.get(cardTeamId));
//            b.setCardTeamId(cardTeamId);
//            playerController.sendMsg(SGMainProto.E_MSG_ID.MsgID_Bag_MyCard_VALUE, b.build().toByteArray());
//        }

        if(cardTeamMap.get(cardTeamId) == null) {
            //参数错误
            playerController.sendAlert(E_NOTIFY_TYPE.NOTIFY_TYPE_WARN, WordFactory.getWord(WordFactory.PARAM_ERROR));
            return;
        }

        battleCardIndex = cardTeamId;
        SGBagProto.S2S_SetBattleCardTeam.Builder b = SGBagProto.S2S_SetBattleCardTeam.newBuilder();
        b.setCardTeamId(cardTeamId);
        System.out.println(b.toString());
        playerController.sendMsg(SGMainProto.E_MSG_ID.MsgID_Bag_SetBattleCardTeam_VALUE, b.build().toByteArray());
    }

    /***
     * 卡片替换使用
     * @param playerController
     * @param activeCardId
     * @param passiveCardId
     */
    public void cardReplace(PlayerController playerController,int cardTeamId,int activeCardId,int passiveCardId){


        SGBagProto.S2C_CardReplace.Builder b = SGBagProto.S2C_CardReplace.newBuilder();
        //在配置文件中获取兵种升级配置
//        PlayerLv lv = DataFactory.getInstance().getGameObject(DataFactory.CARD_LV_KEY,player.lv);
        //获取当前能携带进战斗的兵种数量
//        int battleSoldierCount =  lv.battleSoldierCount;

        System.out.println(" cardTeamId :" + cardTeamId);
        System.out.println(" activeCardId :" + activeCardId);
        System.out.println(" passiveCardId :" + passiveCardId);

        if (cardTeamMap != null && cardTeamMap.size() > ConstantFactory.ZERO) {
            List<Integer> list = cardTeamMap.get(cardTeamId);
            if(list != null && list.size() > ConstantFactory.ZERO){
                SGBagProto.MyCardTeamInfo.Builder c = SGBagProto.MyCardTeamInfo.newBuilder();
                c.setCardTeamId(cardTeamId);
                for(int i = 0 ; i < list.size() ; i++){
                    if(list.get(i) == passiveCardId){
                        list.set(i, activeCardId);
                    }
                    Card card = getCard(list.get(i).intValue());
                    card.battleIndex = cardTeamId;
                    SGBagProto.MyCardBagInfo.Builder v = SGBagProto.MyCardBagInfo.newBuilder();
                    v.setLv(card.getLv());
                    v.setCid(list.get(i));
                    c.addCardInfo(v);
                }
                b.setCardTeamInfo(c);
                System.out.println("返回的数据：" + b.toString());
                //返回给客户端
                //删除原来的卡组
                cardTeamMap.remove(cardTeamId);
                //设置新的卡组
                cardTeamMap.put(cardTeamId, list);

                System.out.println("cardTeamMap:" + cardTeamMap.toString());
                playerController.sendMsg(SGMainProto.E_MSG_ID.MsgID_Bag_SetCardReplace_VALUE, b.build().toByteArray());
            }

        }

    }


    /**
     * 获取当前上阵的卡组
     * @return
     */
    public List<Card> getBattleCardList()
    {
        List<Card> result = new ArrayList<>();
        List<Integer> ids = cardTeamMap.get(battleCardIndex);
        for(Integer id : ids)
        {
            result.add(cardMap.get(id));
        }
        return result;
    }


    /**
     * 获取属性加成
     * @return
     */
    public int getAttributePlus(int attrId)
    {
        return 0;
    }


    //-------------------------------Get Set---------------------------------------------------------------
    public Player getPlayer() {
        return player;
    }

    public void setPlayer(Player player) {
        this.player = player;
    }

    public List<Card> getCardList() {
        return cardList;
    }

    public void setCardList(List<Card> cardList) {
        this.cardList = cardList;
    }

    public Map<Integer, Card> getCardMap() {
        return cardMap;
    }

    public void setCardMap(Map<Integer, Card> cardMap) {
        this.cardMap = cardMap;
    }

    public Map<Integer, List<Integer>> getCardTeamMap() {
        return cardTeamMap;
    }

    public void setCardTeamMap(Map<Integer, List<Integer>> cardTeamMap) {
        this.cardTeamMap = cardTeamMap;
    }

    public Map<Integer, Integer> getAssetData() {
        return assetData;
    }

    public void setAssetbattleCardIndexData(Map<Integer, Integer> assetData) {
        this.assetData = assetData;
    }

    public int getBattleCardIndex() {
        return battleCardIndex;
    }

    public void setBattleCardIndex(int battleCardIndex) {
        this.battleCardIndex = battleCardIndex;
    }



}
